package cn.kgc.auth;

import cn.kgc.mapper.HotelMapper;
import cn.kgc.mapper.UserMapper;
import cn.kgc.pojo.Hotel;
import cn.kgc.pojo.HotelWithBLOBs;
import cn.kgc.pojo.User;
import com.github.pagehelper.PageHelper;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class TestPageHelperAndMapper {
    public static void main(String[] args) {
        HotelMapper hotelMapper=  new ClassPathXmlApplicationContext("spring.xml").getBean(HotelMapper.class);
//        Hotel h= hotelMapper.selectByPrimaryKey(4L);
//       System.out.println(h.toString());
        PageHelper.startPage(3,5,false);
//        Page<Hotel> page=PageHelper.offsetPage(3,5,true);
//        System.out.println(page);
        List<HotelWithBLOBs> list= hotelMapper.selectAll();
        for (Hotel h:list){
          //  System.out.println(h.getHotelname());
        }

        UserMapper userMapper=  new ClassPathXmlApplicationContext("spring.xml").getBean(UserMapper.class);

        User userX=new User();
        userX.setUserCode("840027655@qq.com");

        User userT=userMapper.selectOne(userX);

        userT.setActivated(1);

//        System.out.println(userX.getActivated());
        //3 修改用户的状态为激活\
        userT.setBaidu("aaaaaa");
        int a =userMapper.updateByPrimaryKey(userT);
        System.out.println("aaaa"+a);

    }
}
